﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.JumpAssignedObject.CApJumpAssignedObjectApp
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.JumpAssignedObject;

public class CApJumpAssignedObjectApp
{
  public static ITxLocatableObject GetFlowOperationSimulatedObject(
    TxObjectFlowOperation objectFlowOperation)
  {
    ITxLocatableObject operationSimulatedObject = (ITxLocatableObject) null;
    if (TxObjectFlowOperation.op_Inequality(objectFlowOperation, (ITxObject) null))
      operationSimulatedObject = objectFlowOperation.SimulatedObject;
    return operationSimulatedObject;
  }

  public static ITxLocatableObject GetFlowOperationSimulatedObject(
    TxObjectFlowLocationOperation objFlowLocationOperation)
  {
    ITxLocatableObject operationSimulatedObject = (ITxLocatableObject) null;
    if (TxObjectFlowLocationOperation.op_Inequality(objFlowLocationOperation, (ITxObject) null) && objFlowLocationOperation.Collection != null && objFlowLocationOperation.Collection is TxObjectFlowOperation)
      operationSimulatedObject = CApJumpAssignedObjectApp.GetFlowOperationSimulatedObject(objFlowLocationOperation.Collection as TxObjectFlowOperation);
    return operationSimulatedObject;
  }

  public static TxTransformation GetFlowOperationGripFrame(TxObjectFlowOperation objectFlowOperation)
  {
    TxTransformation operationGripFrame = (TxTransformation) null;
    if (TxObjectFlowOperation.op_Inequality(objectFlowOperation, (ITxObject) null) && objectFlowOperation.GripFrame != null)
      operationGripFrame = objectFlowOperation.GripFrame.AbsoluteLocation;
    if (TxTransformation.op_Equality(operationGripFrame, (TxTransformation) null) && objectFlowOperation.SimulatedObject != null)
      operationGripFrame = objectFlowOperation.SimulatedObject.AbsoluteLocation;
    return operationGripFrame;
  }

  public static TxTransformation GetFlowOperationGripFrame(
    TxObjectFlowLocationOperation objFlowLocationOperation)
  {
    TxTransformation operationGripFrame = (TxTransformation) null;
    if (TxObjectFlowLocationOperation.op_Inequality(objFlowLocationOperation, (ITxObject) null) && objFlowLocationOperation.Collection != null && objFlowLocationOperation.Collection is TxObjectFlowOperation)
      operationGripFrame = CApJumpAssignedObjectApp.GetFlowOperationGripFrame(objFlowLocationOperation.Collection as TxObjectFlowOperation);
    return operationGripFrame;
  }

  public static void MoveSimulatedObject(
    ITxLocatableObject simulatedObject,
    TxTransformation from,
    TxTransformation to)
  {
    TxTransformation txTransformation = TxTransformation.op_Multiply(from.Inverse, to);
    TxObjectList txObjectList = new TxObjectList();
    ((Collection<ITxObject>) txObjectList).Add((ITxObject) simulatedObject);
    TxLocatableObjectEx.SetObjectListLocationOffset(txObjectList, from, txTransformation);
  }

  public static TxObjectFlowLocationOperation GetFirstLocation(TxObjectFlowOperation flowOperation)
  {
    TxObjectFlowLocationOperation firstLocation = (TxObjectFlowLocationOperation) null;
    if (TxObjectFlowOperation.op_Inequality(flowOperation, (ITxObject) null))
    {
      TxObjectList allDescendants = flowOperation.GetAllDescendants((ITxTypeFilter) new TxTypeFilter(typeof (TxObjectFlowLocationOperation)));
      if (allDescendants != null && ((Collection<ITxObject>) allDescendants).Count > 0)
        firstLocation = ((Collection<ITxObject>) allDescendants)[0] as TxObjectFlowLocationOperation;
    }
    return firstLocation;
  }
}
